var a = [1, 3, 1, 4, 3, 5, 1, 6, 2, 3, 7];

function unique(arr) {
  var result = {};
  for (var i = 0; i < arr.length; i++) {
    if (!result[arr[i]]) {
      result[arr[i]] = true;
    }
  }
  return Object.keys(result);
}
// var newArr=unique(a);
// console.log(newArr);

var b = [1, 3, 1, 4, 3, 5, 1, 6, 2, 3, 7,4,8,2];
function unique1(arr){
    var result=[];
    for(let i=0;i<arr.length;i++){
        if(!result.includes(arr[i])){
            result.push(arr[i])
        }
    }
    return result;
}
// var newArr=unique1(b)
// console.log(newArr);


var c = [1, 3, 1, 4, 3, 5, 1, 6, 2, 3, 7,4,8,2,9,11,5,6];
// 用es6的Set去重
function unique2(arr){
    return [...new Set(arr)]
}
var newArr=unique2(c);
console.log(newArr);


